<?php $this->widget('bootstrap.widgets.BootAlert'); ?>

<div class="span11 well">
	<?php
		$build = Buildings::model()->findByPk($_GET['id']);
		$unitType = UnitType::model()->findAll('building_id = ' . $build->id_building . ' and building_lvl <= ' . $build->lvl);
		
		$model = UnitType::model()->findAll();
		
		foreach($unitType as $ut):
		$str = "";
		$arr = explode(":", $ut->resources);
		$res = ResourcesType::model()->findByPk($arr[0]);
		
		$str .= $res->name .": " . $arr[1] . " за одного";
	?>
	
	
	
	<div class="span2 well">
		<img src="images/units/<?= $ut->id ?>.png" />
		
		<?php
			echo CHtml::beginForm($this->createUrl("unit/addUnit"));
		?>
		
		<p>
			<?= $ut->name ?>
		</p>
		<p>
		<?php
			echo CHtml::textField("Count", "1", array("style" => "width:100px;"));
			echo CHtml::hiddenField("Type", $ut->id);
			echo CHtml::hiddenField("id_build", $_GET['id']);
			echo CHtml::label($str, "id");
			
			echo CHtml::submitButton("Добавить");
		?>
		
		</p>
		
		<?php
		echo CHtml::endForm();
	?>
	</div>
	
	
	
	<?php
		endforeach;
	?>
</div>